<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Notepad</title>

    <!-- bootstrap -->
    <link rel="stylesheet" href="./assets/css/bootstrap.min.css" />

    <!-- muiUI -->
    <link rel="stylesheet" href="./assets/plugins/mui/css/mui.min.css">

    <!-- animate.css -->
    <link rel="stylesheet" href="./assets/css/animate.min.css" />

    <!-- 重置样式 -->
    <link rel="stylesheet" href="./assets/css/reset.css" />

    <!-- 公共样式 -->
    <link rel="stylesheet" href="./assets/css/common.css" />

    <!-- 页面独立的 -->
    <link rel="stylesheet" href="./assets/css/UserLogin.css" />

</head>

<body>
    <!-- 用户信息 -->
    <div class="user">
        <div class="avatar wow fadeInUp">
            <img src="./assets/images/avatar.png" />
        </div>

        <div class="notice wow fadeInUp" data-wow-delay="100ms">新注册账号</div>
    </div>

    <form class="login wow fadeInUp" data-wow-delay="200ms">
        <div class="form-group">
            <label for="mobile">手机号</label>
            <input type="mobile" class="form-control" id="mobile" placeholder="请输入手机号" required />
        </div>

        <div class="form-group">
            <label for="password">密码</label>
            <input type="password" class="form-control" id="password" placeholder="请输入密码" required />
        </div>

        <div class="action">
            <button class="btn">绑定账号</button>
        </div>
    </form>
</body>

</html>
<!-- jquery  -->
<script src="./assets/js/jquery.min.js"></script>

<!-- bootstrap -->
<script src="./assets/js/bootstrap.min.js"></script>

<!-- wow.js -->
<script src="./assets/js/wow.min.js"></script>

<!-- muiUI -->
<script src="./assets/plugins/mui/js/mui.min.js"></script>

<!-- axios -->
<script src="./assets/plugins/axios/axios.min.js"></script>

<!-- 自己封装的接口文件 -->
<script src="./assets/plugins/axios/request.js"></script>

<!-- 引入登录判断的文件 -->
<script src="./assets/plugins/login.js"></script>

<script>
    //实例化wow.js
    new WOW().init()

    //给表单绑定点击事件
    $(".login").submit(async function (e) {
        //阻止默事件
        e.preventDefault();
        //获取手机号密码内容
        var mobile = $.trim($("#mobile").val());
        var password = $.trim($("#password").val());
        //手机号正则表达式
        var reg = /^1[3-9]\d{9}/
        if (!reg.test(mobile)) {
            mui.alert("手机号格式不正确");
            return false;
        }
        //密码正则表达式 最少六位
        var reg = /^.{6,}$/
        if (!reg.test(password)) {
            mui.alert("密码格式不正确");
            return false;
        }

        //数据组装
        var data = {
            mobile,
            password
        }

        //发起请求 （通过async异步 await同步操作，获取到接口返回的信息数据）
        var res = await POST({
            url: '/business/register',
            params: data
        })

        //判断是否注册成功
        if (res.code == 0) {
            mui.alert(res.msg)
            return false
        } else {
            mui.alert(res.msg, '注册提醒', '确定', function () {
                //跳转
                location.href = 'login.html'
                return false
            })
        }
    });
</script>